import { fetcher } from "@/app/utils/fetcher"
import useSWR from "swr"

export const useMovieList = () => {
    const {data,error,isLoading,mutate} = useSWR("/api/movies",fetcher)
    return {data,error,isLoading,mutate}
}
export const useBillboard = () => {
    const {data,error,isLoading,mutate} = useSWR("/api/random",fetcher)
    return {data,error,isLoading,mutate}
}


export const useMovie=(id?:number)=>{
    const {data,error,isLoading,mutate} = useSWR(id?`/api/movie/${id}`:null,fetcher,{
        // revalidateOnFocus:false,
        // revalidateOnReconnect:false,
        // revalidateOnMount:false
    })
    return {data,error,isLoading,mutate}
}